# encoding=utf8

import urllib.request
from setuptools.compat import unicode

import bs4
import bs4.element
from main_pachong import conf

def grabContent(url):
    req = urllib.request.Request(url)#,headers=conf.HEADERS)
    html = urllib.request.urlopen(req)

    doc = unicode(html.read(),'GBK','ignore').encode('UTF-8').decode()

    sou = bs4.BeautifulSoup(doc,"html.parser")

    res = sou.find(id="nr1")

    sl = res.find_all('script')

    if sl != None:
        for s in sl:
            s.extract()

    str = res.get_text('\n')

    return str


# if __name__ == '__main__':
#     url = 'http://m.qu.la'+'/book/4687/3741440.html'
#     print( grabContent(url))